
package hasthi.coordinator;

import java.util.List;
import java.util.Vector;

import javax.xml.namespace.QName;

import hasthi.manager.ManagerAddress;

public class RemoteManagerContext implements Comparable<RemoteManagerContext>{
    private final String id;
    private final ManagerAddress address;
    private long lastUpdated = System.currentTimeMillis();
    private final List<QName> assignedResources = new Vector<QName>();
    private final int rank;
    
    public RemoteManagerContext(ManagerAddress address, int rank) {
        this.address = address;
        this.id = address.getSoapAddress();
        this.rank = rank;
    }

    public void addResource(QName resourceName){
        assignedResources.add(resourceName);
    }
    
    public void removeResource(QName resourceName){
        assignedResources.remove(resourceName);
    }

    
    public long getLastUpdated() {
        return lastUpdated;
    }
    public void setLastUpdated(long lastUpdated) {
        this.lastUpdated = lastUpdated;
    }
    public List<QName> getAssignedResources() {
        return assignedResources;
    }

    public ManagerAddress getAddress() {
        return address;
    }

    public String getId() {
        return id;
    }

    public int compareTo(RemoteManagerContext o) {
        return rank - o.rank;
    }
}

